package com.sky;

import java.util.Scanner;

public class Sort {
    public static void bubbleSort(int[] arr) {  
        int n = arr.length;  
        for (int i = 0; i < n - 1; i++) {  
            for (int j = 0; j < n - i - 1; j++) {  
                if (arr[j] > arr[j + 1]) {  
                    // 交换 arr[j] 和 arr[j+1]  
                    int temp = arr[j];  
                    arr[j] = arr[j + 1];  
                    arr[j + 1] = temp;  
                }  
            }  
        }  
    }  
  
    public static void main(String[] args) {  
        Scanner input = new Scanner(System.in);
        int[] sort = new int[10];  
        System.out.println("请输入10个排序的数据：");  
        for (int i = 0; i < sort.length; i++) {  
            sort[i] = input.nextInt();  
        }  
  
        bubbleSort(sort);  
  
        System.out.println("排列后的顺序为：");  
        for (int i = 0; i < sort.length; i++) {  
            System.out.print(sort[i] + " ");  
        }  
    }  
}